package dk.ihk.ssgroup5;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LogoutServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		
		HttpSession session = request.getSession();
		Object userObject = session.getAttribute("user");
		
		if(userObject == null){
			RequestDispatcher dispatcher = request.getRequestDispatcher ("/DesignServlet?pageId=1&navId=1");
			dispatcher.forward(request, response);
			return;	
		}
		
		session.setAttribute("user", null);
		
		RequestDispatcher dispatcher = request.getRequestDispatcher ("/DesignServlet?pageId=8&navId=1");
		
		dispatcher.forward(request, response);
		
		return;	
		
	}

}
